﻿using System;
using Balloonerds.Algebra;

namespace RayTracer
{
    public class Spotlight : Light
    {
        protected double minusCosAngle;

        public Vector Direction { get; set; }
        public double Angle
        {
            get { return Math.Acos(-minusCosAngle); }
            set { minusCosAngle = -Math.Cos(value); }
        }

        public override bool IsIlluminating(Ray ray)
        {
            return Direction * ray.Direction < minusCosAngle;
        }
    }
}
